﻿#ifndef PARAMCONFIG_H
#define PARAMCONFIG_H

#include <QObject>
#include <QSettings>
class ParamConfig : public QObject
{
    Q_OBJECT
public:
    explicit ParamConfig(QObject *parent = nullptr);

    static ParamConfig* instance()
    {
        if (!inst)
        {
            inst = new ParamConfig();
            inst->Init();
        }
        return inst;
    }
    ~ParamConfig();
    void Init();

    inline void SetDeviceNo(int devNo)
    {
        devSetting->setValue("DeviceInformation/DeviceNo", devNo);
        //sync();
    }

    inline int GetDeviceNo()
    {
        return devSetting->value("DeviceInformation/DeviceNo").toInt();
    }

    inline void SetServerIP(QString serverIP)
    {
        devSetting->setValue("DeviceInformation/ServerIP", serverIP);
        //sync();
    }

    inline QString GetServerIP()
    {
        QString serverIP = devSetting->value("DeviceInformation/ServerIP").toString();
        return serverIP;
    }

    inline void SetServerPort(int ServerPort)
    {
        devSetting->setValue("DeviceInformation/ServerPort", ServerPort);
        //sync();
    }

    inline int GetServerPort()
    {
        int serverPort = devSetting->value("DeviceInformation/ServerPort").toInt();
        return serverPort;
    }

    inline void SetTotalLayers(int layers)
    {
        devSetting->setValue("DeviceInformation/LayerCount", layers);
        //sync();
    }

    inline int GetTotalLayers()
    {
        return devSetting->value("DeviceInformation/LayerCount").toInt();
    }

    inline void SetCellCount(int cellCount)
    {
        devSetting->setValue("DeviceInformation/CellCount", cellCount);
        //sync();
    }

    inline int GetCellCount()
    {
        return devSetting->value("DeviceInformation/CellCount").toInt();
    }

    inline QString GetSystemVersion()
    {
       return devSetting->value("DeviceInformation/SystemVersion").toString();
    }

    inline void SetSystemVersion(QString systemVersion)
    {
        devSetting->setValue("DeviceInformation/SystemVersion",systemVersion);
        //sync();
    }

    inline QString GetDeviceModel()
    {
       return devSetting->value("DeviceInformation/DeviceModel").toString();
    }

    inline void SetDeviceModel(QString deviceModel)
    {
        devSetting->setValue("DeviceInformation/DeviceModel",deviceModel);
        //sync();
    }

    inline QString GetCabinetName()
    {
       return devSetting->value("DeviceInformation/CabinetName").toString();
    }

    inline void SetCabinetName(QString cabinetName)
    {
        devSetting->setValue("DeviceInformation/CabinetName",cabinetName);
        //sync();
    }
signals:
private:
    static ParamConfig* inst;
    static QSettings    *devSetting ;

};

#endif // PARAMCONFIG_H
